package de.homer.adapter.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author André Stannek
 * 
 */
@Entity
@Table(name = "knownPlugins")
@XmlRootElement
public class PluginMetaInformation {

	/**
	 * 
	 */
	@Id
	@Column(name = "className")
	private final String pluginClassName;

	/**
	 * 
	 */
	@Column(name = "jar")
	private String jarPath;

	/**
	 * 
	 */
	@Column(name = "name")
	private final String name;

	/**
	 * 
	 */
	@ElementCollection
	private final Set<String> configurableAttributes;

	/**
	 * 
	 */
	@ElementCollection
	private final Set<String> pluginInterfaces;

	/**
	 * Default constructor should only be used by hibernate.
	 * 
	 * @deprecated default constructor is needed by hibernate but should not be
	 *             used. Use the other one because you have to initialize those
	 *             values if you want to use this class properly.
	 */
	@Deprecated
	protected PluginMetaInformation() {
		super();
		pluginClassName = "";
		name = "";
		configurableAttributes = new HashSet<>();
		pluginInterfaces = new HashSet<>();
	}

	/**
	 * @param pluginClassName
	 *            the fully qualified classname of the plugin.
	 * @param pluginInterfaces
	 *            all {@link de.homer.adapter.interfaces.HomeRPlugin} interfaces
	 *            directly(!) implemented by the plugin.
	 * @param name
	 *            the name of the plugin.
	 * @param configurableAttributes
	 *            the set of attributes of the plugin
	 */
	public PluginMetaInformation(final String pluginClassName,
			final Set<String> pluginInterfaces, final String name,
			final Set<String> configurableAttributes) {
		super();
		this.pluginClassName = pluginClassName;
		this.name = name;
		this.configurableAttributes = configurableAttributes;
		this.pluginInterfaces = pluginInterfaces;
	}

	/**
	 * @return the adapterClassName
	 */
	public final String getPluginClassName() {
		return pluginClassName;
	}

	/**
	 * @return the fully qualified path to the jar file containing the plugin
	 *         class.
	 */
	public final String getJarPath() {
		return jarPath;
	}

	/**
	 * @return the name
	 */
	public final String getName() {
		return name;
	}

	/**
	 * @return the configurableAttributes
	 */
	public final Set<String> getConfigurableAttributes() {
		return configurableAttributes;
	}

	/**
	 * @param jarPath
	 *            the jarPath to set
	 */
	public final void setJarPath(final String jarPath) {
		this.jarPath = jarPath;
	}

	/**
	 * @return the pluginInterfaces
	 */
	public final Set<String> getPluginInterfaces() {
		return pluginInterfaces;
	}
}
